package cn.lytcom.architecture.data;

import android.content.Context;

import cn.lytcom.architecture.api.AppRestQueue;
import cn.lytcom.architecture.manager.DbManager;
import cn.lytcom.architecture.manager.SpManager;
import cn.lytcom.architecture.model.User;
import io.reactivex.Observable;

/**
 * Created by lytcom on 2017/5/14.
 */

public class DataProvider implements IDataProvider {

    private Context context;
    private AppRestQueue appRestQueue;
    private DbManager dbManager;
    private SpManager spManager;

    public DataProvider(Context context, AppRestQueue appRestQueue, DbManager dbManager, SpManager spManager) {
        this.context = context;
        this.appRestQueue = appRestQueue;
        this.dbManager = dbManager;
        this.spManager = spManager;
    }

    @Override
    public Observable<User> getUserByName(String name) {
        return Observable.concat(dbManager.getUserByName(name), appRestQueue.getUerByName(name))
            .firstElement()
            .toObservable();
    }
}
